from flask import request
from SQLOperation.UserSQLOperation import UserSQLOperation
from SQLConfig import app


@app.route('/login', methods=['Get', 'POST'])
def login():  # put application's code here
    """
    用户登录
    """
    username = request.json.get("username")
    password = request.json.get("password")
    user = UserSQLOperation.searchByUsername(username)
    if user is None:
        return "user not exist"
    elif user.password == password:
        return "OK"
    else:
        return "password wrong"
